package main

import (
	"errors"
	"net/rpc"
	"net"
	"log"
	"net/http"
)

type Args struct  {
	A,B int
}

type Quotient struct {
	Quo,Dim int
}

type Arith int

func (t *Arith) Multply(args *Args, repay *int) error {
	*repay = args.A * args.B
	return nil
}

func (t *Arith) Divide(args *Args,quotient *Quotient) error  {
	if args.B ==0 {
		return errors.New("被除数不能为空")
	}
	quotient.Quo = args.A/args.B
	quotient.Dim = args.A%args.B
	return nil
}

func main() {
	arith := new(Arith)
	rpc.Register(arith)
	rpc.HandleHTTP()
	l,err := net.Listen("tcp",":1234")
	if err != nil {
		log.Fatal("lisn error ",err)
	}
	http.Serve(l,nil)
	
}

